<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
	<%
	StringBuffer strURL = request.getRequestURL();
	String URL = strURL.toString();
	String contPath = request.getContextPath();
	int nIndex = URL.indexOf(contPath);
	URL = "http://tugo.cn/weixin_aef/";
	%>
<html>

<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta content="always" name="referrer">
<meta charset="utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<!-- 移动端必须的设置 -->
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<!-- 禁用电话号码检测功能，禁止对数字随便可以拨号 -->
<meta name="format-detection" content="telephone=no">
<!-- 禁用E-mail检测功能 -->
<meta name="format-detection" content="email=no">
<!-- 禁用地址检测功能，禁止跳转到地图 -->
<meta name="format-detection" content="address=no">
<!-- 在苹果设备上以全屏方式打开本网页 -->
<meta name="apple-mobile-web-app-capable" content="yes">
<!-- 设置在苹果设备上状态的颜色，默认白色，要设置成什么颜色以Web颜F色的风格而定 -->
<meta name="apple-mobile-web-app-status-bar-style" content="white">
<title>途狗收油</title>
<script type="text/javascript" src="<%=URL%>js/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="<%=URL%>js/base64.js"></script>
<script type="text/javascript" src="<%=URL%>js/layui/layui.js "></script>
<script type="text/javascript" src="<%=URL%>vendor/resize.js"></script>
<script type="text/javascript" src="<%=URL%>js/doT.min.js"></script>
<link rel="stylesheet" href="<%=URL%>js/layui/css/layui.css" />
<link rel="stylesheet"
	href="<%=URL%>vendor/font-awesome/css/font-awesome.min.css" />
<link rel="stylesheet" href="<%=URL%>css/basestyle.css" />
<link rel="stylesheet" href="<%=URL%>vendor/iconfont/iconfont.css" />
<link rel="stylesheet" href="<%=URL%>css/unread-notice.css" />
<script type="text/javascript" src="<%=URL%>js/cookies.js?version=1.1"></script>
<script type="text/javascript" src="<%=URL%>newedition/js/base.js?version=3.6"></script>
</head>

<body>
	<div class="header">
		<div class="header-top">
		<%-- 	<a href="<%=URL%>salesman/user_infoList.jsp"><i class="icon iconfont icon-fanhui"></i></a> --%> <span style="color: #202a43;">消息通知</span> <i
				class="icon iconfont " style="color: #202a43;"></i>
		</div>
		<ul id="taball">
			<li class="active-nav" name="0">未读</li>
			<li name="1">已读</li>
		</ul>
	</div>
	<div id="dotmainhtml">
	</div>
	<script type="template" id="dotTmpl">
	
	{{if(it.length!=0){ }}
	<div class="main">
    {{ for(var i=0;i<it.length;i++){	}}	
		<p class="time">{{=it[i].createdDt}}</p>
		<ul class="mainul">
			<li name="{{=it[i].id}}"><a> <i class="icon iconfont icon-iconnew16"></i>
					<div class="words">
						<h3>{{=it[i].title}}</h3>
						<p>{{=it[i].content}}</p>
					</div> 
			</a></li>
			
		</ul>
		{{ }	}}
	</div>
	{{}}}
	{{else{}}
			<div class="main" style="height: 3rem;margin-top: 2rem;text-align: center;">
			<i class="icon iconfont icon-weibiaoti1" style="font-size: 2rem;"></i>
			<p>暂时没有消息哟。。。</p>
			</div>
	{{ }}}
	
</script>


	<script>
		$(function() {
			 layui.use('layer', function(){
				})
			messagefindlist(0)
		})
		function messagefindlist(isread){
			var jsonstr = "filterscount=0&groupscount=0&pagenum=0&pagesize=20&recordstartindex=0&recordendindex=20&userid="+getCookie("salesmanid")+"&isread="+isread+"";
			$.ajax({
					cache : false,
					type : "post",
					datatype : 'json',
					contentType : 'application/json;charset=UTF-8',
					data : jsonstr,
					url : 'http://118.178.18.0:8082/alfa-mobile-ws/rest/message/findlist?mobiletoken='+getCookie("mobiletokensalesman")+'',
					success : function(data) {
							var tmpl = doT.template($("#dotTmpl").html());
							// 将数据扔进templ中。并在DIV中显示出来
							$("#dotmainhtml").html(tmpl(data.rows));
							 tabclick();
						}
				});
		}
		function tabclick(){
			$("#taball").children("li").on("click", function() {
				$("#taball").find("li").removeClass("active-nav");
				$(this).addClass("active-nav");
				if($(this).attr("name")=="0"){
					var index = layer.load(2, {
						shade: [0.1, '#fff'],
						time: 2000
					});
					messagefindlist(0)
				}else{
					var index = layer.load(2, {
						shade: [0.1, '#fff'],
						time: 2000
					});
					messagefindlist(1)
				}
			})
			$(".mainul").children("li").on("click", function() {
				var displaytype = $(this).find("p").css('display');
				isread($(this).attr("name"))
				if (displaytype == "-webkit-box") {
					$(this).find("i").css('color', "#31ffc9");
					$(this).find("p").css('display', "block");
				} else {
					$(this).find("p").css('display', "-webkit-box");
				}
			})
		}
		function isread(id){
			var json = {
					"userid": ""+getCookie("userid")+"",
					"messageid": ""+id+"",
					"isread":"1",
				}
			$.ajax({
				cache : false,
				type : "post",
				datatype : 'json',
				contentType : 'application/json;charset=UTF-8',
				data : JSON.stringify(json),
				url : 'http://118.178.18.0:8082/alfa-mobile-ws/rest/message/isread?mobiletoken='+getCookie("mobiletokenuser")+'',
				success : function(data) {
					if(data.message=="1"){
					}else{
					}
				}
			})
		}
	</script>
</body>

</html>